@inherits BaseEditor
@using BlazorDatasheet.Util
@using BlazorDatasheet.Core.Interfaces
@using BlazorDatasheet.Core.Data
@using BlazorDatasheet.Core.Edit

<input
    type="text"
    class="text-input"
    @bind="CurrentValue"
    @bind:event="oninput"
    style="@CssUtil.GetStyledInput(Cell)"
    @ref="InputRef"/>

@code {

    private IReadOnlyCell Cell;

    public override void BeforeEdit(IReadOnlyCell cell, Sheet sheet)
    {
        Cell = cell;
    }

    public override void BeginEdit(EditEntryMode entryMode, string? editValue, string key)
    {
        if (entryMode == EditEntryMode.Key && !String.IsNullOrEmpty(key) && key.Length == 1)
        {
            CurrentValue = key;
        }
        else
        {
            CurrentValue = editValue?.ToString() ?? string.Empty;
        }
    }

    protected override void OnAfterRender(bool firstRender)
    {
        base.OnAfterRender(firstRender);
    }

}